#!/usr/bin/python3

import logging.handlers


from pwdBase import getPwd
from  baseSql import *
from dbPool import *

class CSysTemListMgr:
    tableTitle = ["序号", "客户", "系统类型", "产品线", "交易所",
                  "系统编号", "别称", "审批编号", "机房", "管理IP",
                  "硬件版本", "软件版本", "驱动版本", "板卡类型", "网卡类型",
                  "系统状态", "备注", "最近更新"]
    def __init__(self, log):
        self.log=log
        self.systemList = [self.tableTitle]

    def init(self, db):
        self.db = db
        self.reload()


    # 按字段名获取序号
    def getIndexByName(self, name=""):
        if(name == ""):
            return ""
        else:
            for index in range(0, len(self.tableTitle)):
                if self.tableTitle[index] == name:
                    return index

    def reload(self):
        self.systemList.clear()
        # 表格的第一条数据
        self.systemList = [self.tableTitle]
        self.db.query(queryAllTableSql + t_system_list)
        rows = self.db.getData()
        # 表格的每一条数据
        for row in rows:
            valueRow = []
            # 添加每一个字段
            for index in range(len(self.tableTitle)):
                valueRow.append(str(row[index]))
            self.systemList.append(valueRow)

        self.log.log("load system list data finish")

    def add(self, customer, productType, productLine = "", room="", systemNum="",
            secondName="", auditNum=""):
        pass